<?
/**
 *左边导航栏输出类.
 *调用函数output()自动输出左边栏.
 */
class LeftNavi{
    /**
     *左边栏可访问页面数组
     *var array
     */
    private $leftNaviArray=array();

    /**
     *左边栏可访问页面集对应文本,即$_auth_group
     *var array
     */
    private $leftNaviArrayT=array();

    /**
     *构造函数.
     *这里传入$limit和urls作为左边栏显示判定，是因为urls会出现partner.html和partner.html?dtype=1情形,
     *单独只通过urls无法判定完全。
     *param array $_auth
     *param array $leftNaviArrayT
     *param int $limit  用户身份类型
     *param array $urls 可访问页面文件
     */
    public function __construct($_auth,$leftNaviArrayT,$limit,$urls){
        $this->leftNaviArrayT=$leftNaviArrayT;
        foreach($_auth as $mod=>$row){
            if($_SESSION['memberID']==7132  || $_SESSION['memberID']==7133 || $_SESSION['memberID']==7134
            || $_SESSION['memberID']==7135  || $_SESSION['memberID']==7136 || $_SESSION['memberID']==7137
            || $_SESSION['memberID']==7157  || $_SESSION['memberID']==27583|| $_SESSION['memberID']==27584
            || $_SESSION['memberID']==27585 || $_SESSION['memberID']==35666|| $_SESSION['memberID']==35668)
            if($row['url'][0]=='orderReport.html'||$row['url'][0]=='buyOrderReport.html' )continue;
            if(!in_array($row['url'][0],$urls)) continue;
            if(!in_array($limit,explode(",",$row['limit']))) continue;
            $this->leftNaviArray[]=$row;
        }
    }

    /**
     *输出左边栏html函数.
     *由用户身份自动完成左边栏的输出。
     */
    public function output(){
        $out_array=array();
        foreach($this->leftNaviArray as $mode=>$row){
            if($row['left']=="none") continue;//不在左边栏显示
            $out_array[$row['group']][]=$row;
        }
        ?>
        <dl class="membdl">
            <?foreach($out_array as $k=>$items){?>
                <dt><?=$this->leftNaviArrayT[$k]?></dt>
                <?foreach($items as $row){?>
                    <dd><a href="<?=$row['url'][0]?>" target="<?=$row['target']?>"><?=$row['title']?></a><i><?=$row['hot_icon']?></i></dd>
                <?}?>
            <?}?>
        </dl>
    <?
    }
}